package com.cl.short_video_java.web.common;

import com.cl.short_video_java.annotation.Log;
import com.cl.short_video_java.annotation.LoginLog;
import com.cl.short_video_java.annotation.NoRepeatSubmit;
import com.cl.short_video_java.common.Result;
import com.cl.short_video_java.dto.MailDto;
import com.cl.short_video_java.menum.MessageType;
import com.cl.short_video_java.service.VideoUserService;
import com.cl.short_video_java.service.impl.MailService;
import com.cl.short_video_java.vo.Login;
import com.cl.short_video_java.vo.Register;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Author 付
 * @Date 2024-11-01 18:01
 * @Version 1.0
 * @description
 * @since 1.0
 */
@RestController
@RequestMapping("/common")
public class LoginController {

	private VideoUserService videoUserService;
	private MailService mailService;

	@Autowired
	public LoginController(VideoUserService videoUserService, MailService mailService) {
		this.videoUserService = videoUserService;
		this.mailService = mailService;
	}

	@PostMapping("/login")
	@NoRepeatSubmit(lockTime = 1)
	public Result login(@Validated @RequestBody Login login, HttpServletRequest request) {
		Map<Object, Object> b = videoUserService.login(login, request);
		return Result.success(b);
	}

	@PostMapping("/register")
	public Result register(@Validated @RequestBody Register register, HttpServletRequest request) {
		Map<Object, Object> b = videoUserService.register(register, request);
		return Result.success(b);
	}

	@GetMapping("/account")
	@NoRepeatSubmit(lockTime = 1)
	public Result getAccount() {
		return Result.success(videoUserService.account());
	}
}
